<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>文章管理- Layui</title>
<link rel="stylesheet" href="/layui/css/layui.css">
<link rel="stylesheet" href="/css/admin.css">
<link rel="stylesheet" href="/css/mypage.css">

</head>
<body>
<div class="layui-layout layui-layout-admin">
  <div class="layui-header">
    <!-- 头部区域（可配合layui已有的水平导航） -->
     @include('admin.header')
  </div>
  <div class="layui-side layui-bg-black">
     @include('admin.left')
  </div>
  <div class="layui-body">

   <form action="search" method="post">
    <div class="layui-form-item" >
     <label class="layui-form-label">时间搜索</label>
      <div class="layui-input-inline">
        <input type="text" name="date1" id="date1" lay-verify="date" placeholder="" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this})">
        </div>
        <div class="layui-input-inline">
        <input type="text" name="date2" id="date2" lay-verify="date" placeholder="" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this})">
        </div>     
      <div class="layui-form-mid layui-word-aux" style="margin-top: -5px"> <button class="layui-btn layui-btn-small layui-btn-normal" sytle="">GO</button></div>
    </div>
    <div class="layui-form-item" ">
        <label class="layui-form-label">关键字</label>
        <div class="layui-input-inline">
          <input type="text" name="keyword" lay-verify="required" value="" autocomplete="off" class="layui-input">
        </div>
        <div class="layui-form-mid layui-word-aux" style="margin-top: -5px"> <button class="layui-btn layui-btn-small layui-btn-normal" sytle="">GO</button></div>
    </div>
   </form>
      <table class="table table-hover" id="list">
        <tr>
          <th width="145">选择</th>
          <th width="45">ID</th>
          <th width="200">标题</th>
          <th width="550">内容</th>
          <th width="100">作者</th>                       
          <th width="150" >分类</th>
          <th width="200">发布时间</th>                      
          <th width="220">操作</th>
        </tr>
         
       
        <?php foreach ($articles->results as $k=>$v):?>
        <tr>                   
          <td><input type="checkbox"  value="{{$v['id']}}"  /></td>
          <td><?php echo $v["id"] ;?></td>
          <td><?php echo $v["title"] ;?></td>
          <td>
          <?php 
          $con=htmlspecialchars_decode($v["content"]);
           echo substr($con,0,60)."......";
          ?></td>
          <td><?php echo $v["author"]; ?></td>
          <td><?php echo $v["king"]; ?></td>
          <td><?php echo date('Y-m-d H:i:s', $v['addtime']); ?></td>
          <td><a href="change?id={{$v['id']}}">修改</a> <a class="button border-yellow button-little" href="dele?id={{$v['id']}}" onclick="{
                      if (confirm('确认删除?')) {
                          return true;
                      }
                      return false;
                  }">删除</a></td>
        </tr>
       <?php endforeach;?>
    </table>
  
    

    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;">
      <div id="page-v" style="margin-left: 50px"></div>  
    </fieldset> 


      
  
     
     
  
  </div>
  <div class="layui-footer">
    <!-- 底部固定区域 -->

  </div>
</div>
</body>
</html>
<script src="/layui/layui.js"></script>
<script>
//JavaScript代码区域
layui.use('element', function(){
  var element = layui.element(); //导航的hover效果、二级菜单等功能，需要依赖element模块

});

layui.use(['laypage', 'layer'], function(){

  var total = <?php echo $all1; ?>;
  var laypage = layui.laypage
  ,layer = layui.layer;

  //好像很实用的样子，后端的同学再也不用写分页逻辑了。
  laypage({
    cont: 'page-v',
    pages: <?php echo $all1; ?>, //可以叫服务端把总页数放在某一个隐藏域，再获取。假设我们获取到的是18
    curr: function(){ //通过url获取当前页，也可以同上（pages）方式获取
      var page = location.search.match(/page=(\d+)/);
      console.log(page);
      return page ? page[1] : 1;
    }(), 
    jump: function(e, first){ //触发分页后的回调
      if(!first){ //一定要加此判断，否则初始时会无限刷新
        location.href = '?page='+e.curr+'&&s={{$s}}';
      }
    }
  });




});

layui.use(['form', 'layedit', 'laydate'], function(){
  var form = layui.form()
  ,layer = layui.layer
  ,layedit = layui.layedit
  ,laydate = layui.laydate;
  

  

  })




</script>